<template>
    <div class="home">
        <el-container>
        <el-aside width="200px">
            <div class="logo"></div>
            <el-menu
            :router= true
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-submenu index="/">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>    
        <el-menu-item index="users">
              <i class="el-icon-star-on"></i>
              <span>工作列表</span>
        </el-menu-item>
      </el-submenu>
      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
    </el-menu>
        </el-aside>
        <el-container>
            <el-header>
                <i class="myicon myicon-menu toggle-btn"></i>
                 <div class="system-title">管理系统</div>
                 <div>
                     <span class="welcome">
                        <a href="#" style="color:red">{{$store.state.userName}}</a>您好,
                    </span>
                    <el-button @click="quit" type="text">
                        退出
                    </el-button>
                 </div>
            </el-header>
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
    </div>
</template>
<script>
import { quit } from "@/api";
export default {
  data() {
    return {
      userName: "3213"
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    quit() {
      //清空storage
      localStorage.removeItem("userName");
      quit().then(res => {
        console.log(res)
      });
      this.$router.push("/login");
    }
  },
  updated() {
    console.log(this.$store.state.userName);
  }
};
</script>
<style lang="scss" scoped>
.home {
  height: 100%;
  background-color: #e5e5e5;
  .el-menu-admin:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  .el-menu {
    border-right: 0;
  }
  .el-container {
    height: 100%;
  }
  .el-aside {
    background-color: #545c64;
  }
  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #545c64;
  }
  .logo {
    height: 60px;
    background: url(../assets/logo.png) no-repeat;
    background-size: 100%;
    background-color: white;
  }
  .toggle-btn {
    padding: 0 10px;
    margin-left: -20px;
    font-size: 36px;
    line-height: 60px;
    color: white;
    cursor: pointer;
    &:hover {
      background-color: #00635a;
    }
  }
  .system-title {
    font-size: 28px;
    color: white;
  }
  .welcome {
    color: white;
  }
}
</style>